package com.compass.mobile.ui.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import com.compass.mobile.databinding.LayoutTextMessageItemBinding
import com.compass.mobile.framework.adapter.BaseBindViewHolder
import com.compass.mobile.framework.adapter.BaseRecyclerViewAdapter
import com.compass.mobile.framework.ext.gone
import com.compass.mobile.framework.ext.visible
import com.compass.mobile.models.AIMessageInfo


/**
 * Description： 测试 adapter
 * Date:2023/12/8 15:01
 */
class AIAdapter : BaseRecyclerViewAdapter<AIMessageInfo, LayoutTextMessageItemBinding>() {
    override fun onBindDefViewHolder(
        holder: BaseBindViewHolder<LayoutTextMessageItemBinding>,
        item: AIMessageInfo?,
        position: Int
    ) {
        if (item == null) return
        holder.binding.apply {
            if (item.type == 0) {

                leftLayout.visible()
                rightLayout.gone()
                leftMsg.text = item.text

            } else {
                rightLayout.visible()
                leftLayout.gone()
                rightMsg.text = item.text
            }


        }
    }

    override fun getViewBinding(
        layoutInflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): LayoutTextMessageItemBinding {
        return LayoutTextMessageItemBinding.inflate(layoutInflater, parent, false)
    }
}